<template>
  <div class="list-detail">
    <div style="width:220px;height:220px;;margin:13px auto">
      <router-link :to="linkto">
        <img :src="data.thumb" style="width:100%;height:100%;object-fit:cover;" />
      </router-link>
    </div>
    <div style="margin-left:15px">
      <div style="width:100%;height:30px;line-height:30px">
        <span class="sale-money" style="font-size:16px">￥{{data.money_sell | toFixed(2)}}</span>
        <span v-if="data.market_price>=data.money_sell"
          style="text-decoration:line-through;color:#bbb">￥{{data.market_price | toFixed(2)}}</span>
      </div>
      <div class="goods-name"
        style="margin:5px 0;text-overflow: ellipsis;overflow: hidden;white-space: nowrap;width: 90%;">
        <router-link :to="linkto"> {{data.name}} </router-link>
      </div>
      <div
        style="width:100%;height:5%;overflow:hidden;text-overflow:ellipsis;white-space: nowrap;margin:5px 0;font-size:12px;">
        {{data.gift_id}}{{data.no_obsolete?'/'+data.no_obsolete:''}}{{data.gb_code?'/'+data.gb_code:''}}
      </div>
      <div style="width:100%;height:5%;margin:5px 0;font-size:12px;">
        {{data.type_name}}
        <span style="padding-left:5px">{{data.texture == 'null' ? '' : data.texture}}</span>
        <span style="padding-left:5px">{{data.product_size}}</span>
        <span style="padding-left:5px;font-size:12px;">{{data.box_num&&data.box_num>0?data.box_num+'个/箱':''}}</span>
      </div>
      <!-- <div v-if="from==1" style="width:100%;height:5%;margin:5px 0;font-size:12px;">
        {{data.from_name}}{{data.docking_nick?'/'+data.docking_nick:''}}</div> -->
      <div style="width:100%;height:5%;margin:5px 0;font-size:12px;"> 剩余库存：{{data.num}}</div>
      <div style="width:100%;height:5%;overflow:hidden;margin:5px 0;font-size:12px;">
        <!-- 上架时间：{{data.on_sale_time.substring(0,10)}} -->
        <el-button type="primary" size="mini" @click="add_click" style="margin-right:15px;float: right;">+购物车
        </el-button>
      </div>
    </div>
  </div>
</template>
<script>
  export default {
    name: "DjGiftAllocateCard",
    props: {
      data: {
        type: Object,
        default() {
          return {};
        }
      
      },
      linkto: {
        type: Object,
        default: null
        // 点击图片或名称的跳转地址
      }
    },
    created() {
    },
    methods: {
      // 点击添加礼品
      add_click() {
        this.$emit("addclick", this.data);
      }
    }
  };
</script>
<style scoped>
  .list-detail {
    width: 260px;
    height: 400px;
    float: left;
    margin: 0 16px 16px 0;
    border: 1px solid #ccc;
    font-size: 12px;
    color: #888;
    background: #fff;
  }

  .list-detail:hover {
    box-shadow: 4px 4px 3px #dddddd;
    border: 2px solid #3396fc;
  }

  .list-detail .sale-money {
    font-size: 14px;
    padding-right: 20px;
    font-weight: bold;
    color: #000;
  }

  .list-detail .goods-name {
    font-size: 14px;
    width: 100%;
    height: 5%;
    color: #000;
  }
</style>